package com.faiz.algorithm;

import java.util.Random;

//随机数区间扩充
public class RandomExtension {
    private static final Random RANDOM = new Random();

    //把随机数区间[1,7]拓展到[1,10]
    public static int random7() {
        return RANDOM.nextInt(6) + 1;

    }

    public static int random7ToRandom10() {
        int num = 500;
        do {
            num = (random7() - 1) * 7 + random7();
        } while (num > 40);
        return num % 10 + 1;
    }

    public static void main(String[] args) {
        System.out.println(random7ToRandom10());
    }
}
